package org.bonorsoft.modules.wechat.controller;

import org.bonorsoft.common.util.WxTokenAPI;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@Controller
@RequestMapping("/linksucai")
public class LinksucaiController {

    @RequestMapping(value = "/link", method = {RequestMethod.GET, RequestMethod.POST})
    public void link(HttpServletRequest request, HttpServletResponse response) throws IOException {
        try {
            /*//类型：1手动授权，2扫码授权（扫描授权的公众号秘钥为空）
            if (oConvertUtils.isEmpty(weixinAccount.getAccountappsecret())) {
                redirectByAuthType2(request, response, SCOPE);
            } else {
                redirectByAuthType1(request, response, SCOPE);
            }*/
            WxTokenAPI.redirectByAuthType(request, response);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @GetMapping(value = "/openid")
    public void getOpenid(HttpServletRequest request, HttpServletResponse response) throws IOException {
        WxTokenAPI.redirectByAuthType(request, response);
    }


}
